package com.fr.cell.core;

import com.fr.cell.core.layout.LayoutFactory;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.JToolTip;
import javax.swing.UIManager;

public class ScrollToolTip extends JToolTip
{
  public Dimension getPreferredSize()
  {
    Dimension localDimension = super.getPreferredSize();
    if ((localDimension.width > 320) || (localDimension.height > 200))
    {
      setLayout(LayoutFactory.createBorderLayout());
      setBorder(BorderFactory.createEmptyBorder());
      JTextPane localJTextPane = new JTextPane();
      localJTextPane.setContentType("text/html");
      localJTextPane.setEditable(false);
      localJTextPane.setCaretPosition(0);
      localJTextPane.setBackground(UIManager.getColor("ToolTip.background"));
      localJTextPane.setForeground(UIManager.getColor("ToolTip.foreground"));
      localJTextPane.setText(getTipText());
      add(new JScrollPane(localJTextPane), "Center");
      localDimension = new Dimension(localDimension.width + 50, localDimension.height + 50);
      doLayout();
    }
    return localDimension;
  }
}